home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / fly8111-.000 / fly8111- / fly8 / oclassic.c < prev    next >
C/C++ Source or Header  |  1979-12-31  |  2KB  |  91 lines

  1. /* --------------------------------- oclassic.c ----------------------------- */
  2.  
  3. /* This is part of the flight simulator 'fly8'.
  4.  * Author: Eyal Lebedinsky (eyal@ise.canberra.edu.au).
  5. */
  6.  
  7. /* Dynamics of the Classic.
  8. */
  9.  
  10. #include "plane.h"
  11.  
  12.  
  13. extern void FAR
  14. dynamics_classic (OBJECT *p, int action)
  15. {
  16.     POINTER    *ptr;
  17.     int    t;
  18.     VECT    OLDV, A;
  19.     AVECT da;
  20.  
  21.     if (action)
  22.         return;
  23.  
  24.     if (dynamics_input (p))
  25.         return;
  26.  
  27.     ptr = p->pointer;
  28.  
  29. #define ADELTA    (VD90/45*EP->opt[3])
  30.     p->da[Y] = -muldiv (2*EX->ailerons, ADELTA*10, 100);
  31.     p->da[X] = muldiv (EX->elevators, ADELTA*10/2, 100);
  32. #undef ADELTA
  33.  
  34.     if (100 == EX->throttle) {
  35.         t = EP->ab_thrust - EP->mil_thrust;
  36.         t = EP->mil_thrust + muldiv (EX->afterburner, t, 100);
  37.     } else {
  38.         t = muldiv (EX->throttle, EP->mil_thrust, 100);
  39.         if (t < 0)
  40.             t /= 2;        /* reverse thrust is 50% efficient */
  41.     }
  42.  
  43.     dampen (&EX->thrust, t, 8);
  44.     EX->power = muldiv (EX->thrust, 10000, EP->ab_thrust);
  45.  
  46.     t = (EX->afterburner) ? EP->ab_sfc : EP->mil_sfc;
  47.     EX->fuelRate = muldiv (iabs(EX->thrust), t, 60*60/10);
  48.     if ((EX->fuel -= TADJ (EX->fuelRate)) < 0) {
  49.         EX->fuel = 0;
  50.         EX->thrust = 0;
  51.     }
  52.  
  53.     dampen (&p->speed, EX->thrust/4*10, 16);
  54.  
  55.     t = muldiv (EP->MaxRudder, EX->rudder, 100);
  56.     p->da[Z] = muldiv (p->speed, t, VMAX);
  57.  
  58.     da[X] = TADJ (p->da[X]) * VONE;
  59.     da[Y] = TADJ (p->da[Y]) * VONE;
  60.     da[Z] = TADJ (p->da[Z]) * VONE;
  61.     Myxz (p->T, da);
  62.  
  63.     fMroty (p->T, p->siny, p->cosy);
  64.     fMrotx (p->T, p->sinx, p->cosx);
  65.     fMrotz (p->T, p->sinz, p->cosz);
  66.     Mangles (p, p->T, p->a, da[Y]);
  67.  
  68.     Vcopy (OLDV, p->V);
  69.     EX->v[Y] = p->speed;
  70.     Vscale (p->V, p->T[Y], p->speed);    /* faster than VMmul() */
  71.     Vsub (A, p->V, OLDV);
  72.     t = ihypot3d (A);
  73.     if (t >= (VMAX/1000)*st.interval)
  74.         EX->Gforce = VMAX;
  75.     else {
  76.         EX->Gforce = muldiv (t, 1000, st.interval)
  77.                + fmul (GACC, p->T[Z][Z]);    /* pilot's gravity */
  78.     }
  79.  
  80.     if ((EX->flags & PF_ONGROUND) && p->R[Z])
  81.         EX->flags &= ~PF_ONGROUND;
  82.  
  83. /* Mach number.
  84. */
  85.     EX->mach = muldiv (p->speed, 1000, 340*VONE);
  86.  
  87. /* pull up warning time.
  88. */
  89.     EX->misc[8] = 2000;
  90. }
  91.